package com.dyp.demo.indicator;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;

/**
 * {
 *     "status": "UP",
 *     "components": {
 *         "diskSpace": {
 *             "status": "UP",
 *             "details": {
 *                 "total": 965974630400,
 *                 "free": 709541679104,
 *                 "threshold": 10485760,
 *                 "exists": true
 *             }
 *         },
 *         "my": {
 *             "status": "UP"
 *         },
 *         "myOther": {
 *             "status": "UP",
 *             "details": {
 *                 "app": "Alive",
 *                 "author": "chandler"
 *             }
 *         },
 *         "ping": {
 *             "status": "UP"
 *         }
 *     }
 * }
 */
@Component
public class MyOtherHealthIndicator extends AbstractHealthIndicator {
    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        // Use the builder to build the health status details that should be reported.
        // If you throw an exception, the status will be DOWN with the exception message.
        // before builder.up , can check what you want, and depend on the result to builder up detail
        builder.up()
                .withDetail("app", "Alive")
                .withDetail("author", "chandler");
    }
}
